←Select platform

ColorResolutionCommand Constructor(ColorResolutionCommandMode,int,RasterByteOrder,RasterDitheringMethod,ColorResolutionCommandPaletteFlags,RasterColor[])

Summary
Initializes a new instance of the ColorResolutionCommand class with explicit parameters.
Syntax
C#
Objective-C
C++/CLI
Java
Python
- (instancetype)initWithMode:(LTColorResolutionCommandMode)mode  
                bitsPerPixel:(NSInteger)bitsPerPixel  
                       order:(LTRasterByteOrder)order  
             ditheringMethod:(LTRasterDitheringMethod)ditheringMethod  
                paletteFlags:(LTColorResolutionCommandPaletteFlags)paletteFlags  
                     palette:(nullable NSArray<LTRasterColor *> *)palette 
public ColorResolutionCommand( 
   ColorResolutionCommandMode mode,  
   int bitsPerPixel,  
   RasterByteOrder order,  
   RasterDitheringMethod ditheringMethod,  
   int paletteFlags,  
   RasterColor[] palette 
) 
__init__(self,mode,bitsPerPixel,order,ditheringMethod,paletteFlags,palette) # Overloaded constructor 

Parameters

mode
Flags which control the behavior of the command.

bitsPerPixel
The number of bits per pixel to for the conversion. Valid values are 1, 2, 3, 4, 5, 6, 7, 8, 12, 16, 24, 32, 48 and 64.

order
The desired color order for the conversion.

ditheringMethod
Dithering options, useful only when the resulting image requires a palette (when it is 8 bits per pixel or less).

paletteFlags
Palette options, useful only when the resulting image requires a palette (when it is 8 bits per pixel or less).

palette
The palette used when converting the image if  paletteFlags includes the ColorResolutionCommandPaletteFlags.UsePalette flag.

Example
C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing; 
 
 
public void ColorResolutionCommandExample() 
{ 
	RasterCodecs codecs = new RasterCodecs(); 
 
	string srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp"); 
	string destFileName1 = Path.Combine(LEAD_VARS.ImagesDir, "Image1_colorres8.bmp"); 
	string destFileName2 = Path.Combine(LEAD_VARS.ImagesDir, "Image1_colorres4.bmp"); 
 
	// Load the source image from disk 
	RasterImage image = codecs.Load(srcFileName); 
 
	// First color-res it to 8 bits per pixel  using the Netscape palette into a seperate image 
	ColorResolutionCommand cmd = new ColorResolutionCommand(); 
	cmd.Mode = ColorResolutionCommandMode.CreateDestinationImage; 
	cmd.BitsPerPixel = 8; 
	cmd.Order = RasterByteOrder.Rgb; 
	cmd.DitheringMethod = RasterDitheringMethod.None; 
	cmd.PaletteFlags = ColorResolutionCommandPaletteFlags.UsePalette; 
	cmd.SetPalette(RasterPalette.Netscape()); 
	cmd.Run(image); 
 
	RasterImage destImage = cmd.DestinationImage; 
	Assert.IsTrue(destImage.BitsPerPixel == 8); 
 
	// Save it to disk 
	codecs.Save(destImage, destFileName1, RasterImageFormat.Bmp, 8); 
	destImage.Dispose(); 
 
	// Now color-res the image in-place to 4-bits per pixel using the Optimized palette 
	cmd.Mode = ColorResolutionCommandMode.InPlace; 
	cmd.BitsPerPixel = 4; 
	cmd.Order = RasterByteOrder.Rgb; 
	cmd.DitheringMethod = RasterDitheringMethod.None; 
	cmd.PaletteFlags = ColorResolutionCommandPaletteFlags.Optimized; 
	cmd.Run(image); 
	Assert.IsTrue(image.BitsPerPixel == 4); 
 
	// Save it to disk 
	codecs.Save(image, destFileName2, RasterImageFormat.Bmp, 4); 
 
	// Clean Up 
	destImage.Dispose(); 
	image.Dispose(); 
	codecs.Dispose(); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images"; 
} 
Requirements

Target Platforms

Help Version 22.0.2023.5.16
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

Leadtools Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.